#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct stu
{
	char name[20];
	int age;
};
int cmp_stu_by_name(const void* e1, const void* e2)
{
	//strcmp   > --> 1,  == --> 0  ,< --> -1
	return strcmp(((struct stu*)e1)->name, ((struct stu*)e2)->name);
	 
}
#include <stdlib.h>
#include <search.h>
void test2()
{
	struct stu S[] = { {"zhangsan",17},{"lisi",30},{"abbbbbbbbbbbbb",25} };
	int sz = sizeof(S) / sizeof(S[0]);
	qsort(S, sz, sizeof(S[0]), cmp_stu_by_name);
	int i = 0;
	for (i = 0; i < 3; i++)
	{
		printf("%s  %d\n", S[i].name, S[i].age);
	}
}
int main()
{
	test2();
	return 0;
}